//util from midpage
(function(w) {
    w.baiduCproPage = {};

    (function(p) {
        // private
        var hasClass = function(element, className) {
            var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');

            return element.className.match(reg);
        };

        // public
        p.dom = {
            find: function(elementId) {
                if (elementId === "")
                    return;
                return document.getElementById(elementId);
            },
            hasClass: hasClass,
            bind: function(obj, evname, fn) {
                if (obj.addEventListener) {
                    obj.addEventListener(evname, fn, false);
                } else {
                    obj.attachEvent('on' + evname, function() {
                        fn.call(obj);
                    });
                }
            },
            getChildElement: function(parent) {
                var children = [];
                for (var i = 0, len = parent.childNodes.length; i < len; i++) {
                    if (parent.childNodes[i].nodeType === 1) {
                        children.push(parent.childNodes[i]);
                    }
                }
                return children;
            },
            getByClass: function(className) {
                if (document.getElementsByClassName) {
                    return document.getElementsByClassName(className);
                } else {
                    var arr = [],
                        collections = document.getElementsByTagName('*'),
                        len = collections.length;
                    for (var i = 0; i < len; i++) {
                        if (collections[i].className.indexOf(className) > -1) {
                            if (collections[i].className == className) {
                                arr.push(collections[i]);
                            }
                        }
                    }
                    return arr;
                }
            }

            ,
            css: function(element, key) {
                if (!element) {
                    return;
                }
                var obj = element.currentStyle ? element.currentStyle : window.getComputedStyle(element, null);
                return obj[key];
            },
            addClass: function(element, className) {
                if (!hasClass(element, className)) {
                    if (!element.className) {
                        element.className += className;
                    } else {
                        element.className += " " + className;
                    }
                }
            },
            removeClass: function(element, className) {
                if (hasClass(element, className)) {
                    var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
                    element.className = element.className.replace(reg, ' ');
                }
            }
        };
    })(w.baiduCproPage);


    (function(p) {
        // private
        var getTarget = function(e) {
            return e.target || e.srcElement;
        };
        var stopPropagation = function(e) {
            if (e.stopPropagation) {
                e.stopPropagation();
            } else {
                e.cancelBubble = true;
            }
        };

        // public
        p.eventUtil = {
            addEvent: function(element, eventType, eventHandler) {
                eventType = eventType.replace(/^on/i, '').toLowerCase();
                if (element.addEventListener) {
                    element.addEventListener(eventType, eventHandler, false);
                } else {
                    element.attachEvent('on' + eventType, function() {
                        eventHandler(window.event);
                    });
                }
            },
            removeEvent: function(element, eventHandler) {
                eventType = eventType.replace(/^on/i, '').toLowerCase();
                if (element.removeEventListener) {
                    element.removeEventListener(eventType, eventHandler, false);
                } else {
                    element.detachEvent('on' + eventType, eventHandler);
                }
            },
            hover: function(element, hoverHandler, unhoverHandler) {
                this.addEvent(element, "mouseover", function(e) {
                    var target = getTarget(e);
                    while (target != element) {
                        target = target.parentNode;
                    }
                    hoverHandler(target);
                });
                this.addEvent(element, "mouseout", function(e) {
                    var target = getTarget(e);
                    while (target != element) {
                        target = target.parentNode;
                    }
                    unhoverHandler(target);
                });
            },
            enter: function(element, eventHandler) {
                this.addEvent(element, "keydown", function(e) {
                    if (e.keyCode === 13) {
                        eventHandler(e);
                        stopPropagation(e);
                    }
                });
                document.onkeydown = function(e) {
                    var e = e || window.event;
                    if (e.keyCode === 13) {
                        eventHandler(e);
                    }
                };
            },
            click: function(element, eventHandler) {
                this.addEvent(element, "click", function(e) {
                    eventHandler(e);
                });
            }
        };
    })(w.baiduCproPage);


    (function(p) {
        // private

        // public
        p.html = {
            em: function(str, flushWord, color) {
                var patt = new RegExp(flushWord, "ig");
                var color = color || "red";
                str = str.replace(patt, '<font color=' + color + '>' + flushWord + '</font>');
                return str;
            },
            loadCss: function(cssString) {
                var doc = document;
                var style = doc.createElement("style");
                style.setAttribute("type", "text/css");

                if (style.styleSheet) { // IE
                    style.styleSheet.cssText = cssString;
                } else { // w3c
                    var cssText = doc.createTextNode(cssString);
                    style.appendChild(cssText);
                }

                var heads = doc.getElementsByTagName("head");
                if (heads.length) {
                    heads[0].appendChild(style);
                } else {
                    doc.documentElement.appendChild(style);
                }
            },
            loadJs: function(src, callback) {
                var js_script = document.createElement('script');

                js_script.onload = function() {
                    callback();
                };
                js_script.onreadystatechange = function() {
                    if (/loaded|complete/.test(js_script.readyState)) {
                        callback();
                    }
                };
                js_script.src = src;

                var ref_script = document.getElementsByTagName('script')[0];
                ref_script.parentNode.insertBefore(js_script, ref_script);
            },
            getLength: function(source) {
                if (!source) {
                    return "";
                }
                source = String(source);
                source = source.replace(/([^\x00-\xff])/g, "\x241 ");
                return source.length / 2;
            },
            trim: function(str) {
                return str.replace(/^\s+|\s+$/g, '');
            },
            ellipsis: function(str, maxLength) {
                if (!str) {
                    return "";
                }
                if (str.length <= maxLength) {
                    return str;
                } else {
                    return str.substring(0, maxLength - 2) + "..";
                }
            },
            cutString: function(source, length, tail) {
                source = String(source);
                tail = tail || '';
                if (length < 0 || source.replace(/[^\x00-\xff]/g, "ci").length <= length) {
                    return source;
                }
                source = source.substr(0, length).replace(/([^\x00-\xff])/g, "\x241 ")
                    .substr(0, length)
                    .replace(/[^\x00-\xff]$/, "")
                    .replace(/([^\x00-\xff]) /g, "\x241");
                return source + tail;
            },
            select: function(start, end) {
                var total = end - start + 1;
                return Math.floor(Math.random() * total + start);
            }
        };
    })(w.baiduCproPage);

})(window);

(function() {
    var cssText = ["#closeBtn {z-index: 2147483647; text-align: center;color:#C5C5C7; display:block;overflow:hidden; background: url(http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_15.png) no-repeat left top; cursor:pointer;background-position: center;background-size:100% 100%;", "text-decoration: none;  font-weight: 100;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src='http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_15.png',sizingMethod='crop');_background:0;background-position;center;background-size:100% 100%;}",
        "#closeBtn:hover {background: url('http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_hover_15.png') no-repeat left top;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src='',sizingMethod='crop');_background:0;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src='http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_hover_15.png',sizingMethod='crop');background-position: center;background-size:100% 100%;}",
        " #closeWrapper {  position: absolute;  display: inline-block;  zoom:1;  z-index: 2147483648;  }",
        ".closeA ,.closeB{ height:20px;  line-height: 20px;  font-size: 14px;  text-align: center;  color:#000;  margin:0px 0px 1px 0px;  display: block;  width:120px;  position:relative;  text-decoration:none;  background-color:#efefef;  border-bottom: 1px solid #7fccff;  zoom:1;  } ",
        ".closeA:hover, .closeB:hover {  background: #7fccff;  color:#F0F0FB; cursor:pointer;  }",
        ".arr-b {position:absolute;width:11px; height:7px;display: block;right:3px;bottom:-7px;_bottom:-16px;background: url('http://cpro.baidustatic.com/cpro/exp/closead/img/arr_hover.png') no-repeat left top;  } ",
        ".arr-b-hover {  position:absolute;  width:11px;  height:7px;  display: block;  right:3px;  bottom:-7px;  _bottom:-16px;  background: url('http://cpro.baidustatic.com/cpro/exp/closead/img/arr.png') no-repeat left top;  } ",
        "#tipWrapper {position: absolute; transition:.6s;-moz-transition:.6s;-webkit-transition:.6s; top:0px;  left:0px;  z-index: 2147483648;  padding:5px 10px 0px; text-align:left;  background-color: #fafafa;_background-color: #fafafa;*background-color: #fafafa;animation:mymove 5s infinite;-webkit-animation:mymove 5s infinite;}",
        "#tipWrapper .tit {font-family:microsoft Yahei; color:#333333;line-height:22px;height:22px;padding-left:10px; border-left:2px solid #5ea5fc;float:left;padding:2px 0 2px 10px;} ",
        "#tipWrapper .goback ,#tipWrapper .gobackt ,.btn-blue {font-size: 18px;color:#5ea5fc;cursor:pointer;text-decoration: underline;white-space: nowrap;word-wrap: normal;background-color:#fafafa;}",
        "#tipWrapper .goback,#tipWrapper .gobackt  {display: inline-block;zoom:1;margin-left:15px; }",
        "#tipWrapper .question_tit .goback,#tipWrapper .question_tit .gobackt {display: inline-block;zoom: 1;margin: 0 15px 0 10px;font-size:18px;height:22px;line-heighe:22px; } ",

        "#tipWrapper .baidu_logo img {border:0; }",
        "#tipWrapper .question_tit{display:block;text-decoration: none;font-size: 18px; line-height: 25px;color:#333; }",
        "#tipWrapper .question_titp{margin:7px 0;line-height:25px; }",
        "#tipWrapper .mw1 {max-width: 470px;float:left;}",
        "#tipWrapper .question_choice .choice, #tipWrapper .mw1 span {text-decoration: none;width:120px;overflow:hidden;height:25px;line-height: 25px;  display: inline-block;zoom:1; cursor: pointer; color:#5ea5fc; font-size: 20px; padding-right:30px; zoom:1;}",
        "#tipWrapper .mw1 span {margin-right: 10px; height:15px; line-height: 15px; display: inline-block; cursor: pointer; color: #666666; font-size: 12px; width: 42%; overflow: hidden; text-overflow: ellipsis; background: url('http://cpro.baidustatic.com/cpro/exp/closead/img/ico_mulsel_gray.png') no-repeat left center; padding-left:20px; zoom: 1;  }",
        "#tipWrapper .mw1 .checked{ background: url('http://cpro.baidustatic.com/cpro/exp/closead/img/ico_mulsel_blue.png') no-repeat left center; }",
        "#tipWrapper.min_90 .question_choice .choice{ height:20px; line-height:20px; }",
        "#tipWrapper.min_90 .question_tit{ line-height:20px; }",
        "#tipWrapper .btn-sub { display: inline-block; zoom:1;width: 80px; height: 25px; line-height: 25px; font-size: 14px; background: none repeat scroll 0% 0% rgb(51, 132, 255); text-align: center; color: rgb(255, 255, 255); float: left; margin-left: 100px; cursor: pointer; }",
        "#tipWrapper.tipWrapper .question_choice .choice{ height:20px; line-height:20px; }",
        "#closePop{ clear:both;height:90px; }",
        "#closePop .space{ padding-left:10px; }",
        "#closePop .space .panel-cause{ position: relative; z-index:2; }",
        "#closePop p{ clear:both; font-size:12px; color:#333; line-height:30px;_line-height:30px; }",
        "#tipWrapper.tipWrapper #closePop p{ line-height:20px; }",
        "#closePop .btns{ clear:both;*clear:none;font-size:12px; color:#333; line-height:0; }",
        "#closePop .sel-panel{ position:relative; height:20px; display:inline-block; *zoom: 1; cursor:pointer; }",
        "#closePop .sel-panel .ipt-other{ position:absolute;left:0;top:0; z-index:1; padding:0 5px; width:120px;_width:120px; height:20px; line-height:20px; border: 1px solid #d2d2d2;  color:#999; font-family:'microsoft yahei'; font-size:12px;_line-height:20px;_height:20px;  }",
        "#closePop select{ width:131px; height:22px; line-height:20px; border:1px solid #d2d2d2; color:#999; font-size:12px; }",
        "#closePop .causeSelect{ display:none; position:absolute; left:0; top:21px; z-index:99; width:129px; border:1px solid #d2d2d2; color:#999; font-size:12px; background-color:#fff; }",
        "#closePop .causeSelect li{ padding: 0 5px; height:24px; line-height:24px; position:relative; z-index:99; }",
        "#closePop .show-cause{ position:absolute; left:0; top:0; padding: 0 5px; width:119px; height:20px; line-height:20px; border:1px solid #d2d2d2; color:#999; font-size:12px; display:inline-block; zoom:1; background: #fff url('http://cpro.baidustatic.com/cpro/ui/noexpire/img/2.0.0/radio_btn.png') no-repeat right -85px; }",
        "#closePop .sel-panel.on .show-cause{ background-position: right -106px; }",
        "#closePop .ok-btn{ _position:absolute; _z-index:-1; width:65px; height:20px; line-height:20px; margin-top:15px; text-align:center; color:#5ea5fc; text-decoration:none; display:inline-block; zoom:1; background:url('http://cpro.baidustatic.com/cpro/ui/noexpire/img/2.0.0/radio_btn.png') no-repeat 0 -43px; }",
        "#closePop .ok-btn:hover{ background:url('http://cpro.baidustatic.com/cpro/ui/noexpire/img/2.0.0/radio_btn.png') no-repeat 0 -64px; color:#fff; }",
        "#tipWrapper.wrapper_small .question_choice .choice{ text-decoration:none; }",
        "#tipWrapper.wrapper_small #closePop p{ line-height:20px; }",
        "#tipWrapper.wrapper_small #closePop .space{ padding-left:0; }",
        "#tipWrapper.wrapper_small #closePop .i-email{ width:89px;float:left; }",
        "#tipWrapper.wrapper_small #closePop .sel-panel .ipt-other{ width:89px; }",
        "#tipWrapper.wrapper_small #closePop .show-cause{ width:89px; }",
        "#tipWrapper.wrapper_small #closePop .causeSelect{ width:99px; }",
        "#tipWrapper.wrapper_small .question_tit{ line-height:20px; }",
        "#tipWrapper.min_hei .question_choice .choice{ width: auto; }",
        "#tipWrapper.wrapper_panel #closePop .space .panel{ float:left; _width:132px; }",
        "#tipWrapper.min_90 #closePop .causeSelect{ top:-61px }",
        "#tipWrapper.min_90 #closePop .causeSelect li{ height:15px; line-height:15px; }",
        "#tipWrapper.wrapper_panel #closePop .panel-email{ margin-left:20px; }",
        "#tipWrapper.wrapper_panel #closePop .btns{ float:left;position:relative; top:16px;left: 20px; }",
        "#tipWrapper.min_90 .complaint,#tipWrapper.min_90 .question_choice{ float:left; }",
        "#tipWrapper.min_hei.wrapper_panel #closePop .panel-email{ margin-left:0; }",
        "#closePop .i-email{ width:119px; height:20px; line-height:20px; padding: 0 5px; border: 1px solid #d2d2d2; font-size:12px; color:#666; font-family:'microsoft yahei' }", "#closeCon{overflow:hidden;position:absolute;left:0;bottom:0;z-index:2147483647;}",
        "#closeWrap{position:relative;left:0;bottom:0;z-index:2147483647;width:20px;height:20px;transition:all .3 ease; -webkit-transigion: all .3 ease;690}",
        ".pop-dialog{ background-color:#fff;position:absolute;left:0; top:0; width:100%;height:100%; }",
        ".pop-dialog .closeBtn{ cursor:pointer; position:absolute; bottom:0; left:0; z-index:9; display:block; width:15px; height:15px; background:url(http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_15.png) no-repeat 0 0; }",
        ".pop-dialog .closeBtn:hover{ background:url(http://yf-sys-rath5-c32-nova25.yf01.baidu.com:8090/images/bd_close_hover_15.png) no-repeat 0 0; }",
        ".pop-dialog .sel_radio{ position:relative; /*float:right;*/ display:block; font-size:0.29rem; text-decoration:none; color:#fff; text-align:center; }",
        ".pop-dialog .sel_radio.s1{ background-color:#7eccff; background: -moz-linear-gradient(top, #60bbfd 5px, #7eccff 14px); background: -webkit-gradient(linear, left top, left bottom, color-stop(5px,#60bbfd), color-stop(14px,#7eccff)); background: -webkit-linear-gradient(top,  #60bbfd 5px,#7eccff 14px); background: -o-linear-gradient(top, #60bbfd 5px,#7eccff 14px); background: -ms-linear-gradient(top, #60bbfd 5px,#7eccff 14px); background: linear-gradient(to bottom, #60bbfd 5px,#7eccff 14px); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#60bbfd', endColorstr='#7eccff',GradientType=0 ); }",
        ".pop-dialog.fl .sel_radio.s1{ background: -moz-linear-gradient(left, #60bbfd 5px, #7eccff 14px); background: -webkit-gradient(linear, left left, left right, color-stop(5px,#60bbfd), color-stop(14px,#7eccff)); background: -webkit-linear-gradient(left,  #60bbfd 5px,#7eccff 14px); background: -o-linear-gradient(left, #60bbfd 5px,#7eccff 14px); background: -ms-linear-gradient(left, #60bbfd 5px,#7eccff 14px); background: linear-gradient(to right, #60bbfd 5px,#7eccff 14px); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#60bbfd', endColorstr='#7eccff',GradientType=0 ); }",
        ".pop-dialog .sel_radio.s2{ background-color:#71bcfe; }",
        ".pop-dialog .sel_radio.s3{ background-color:#5ea5fc; }",
        ".pop-dialog .trapezium{float:left;position:relative;animation:mymove 5s infinite;-webkit-animation:mymove 5s infinite;}",
        ".pop-dialog .triangle_left{width:0;height:0;border-top:50px solid transparent;border-left:20px solid #408fef;border-bottom:20px solid transparent;position:absolute;z-index:9;}",
        ".zfx{width:140px;height:140px;float:left;background:#408fef;display:block;text-align:center;line-height:30px;}",
        ".choiceWrap .choice{text-decoration:none;color:#5ea5fc;}",
        ".choiceWrap a{float:left;font-size:18px;padding:0 10px;line-height:40px;}",
        "#closeEnd{height:90px;}",
        "#closeChoice{height:90px;}",
        "#Countdown{position:absolute;top:0;left:0;font-size:14px;display:none;color;orange;}"

    ].join('');


    baiduCproPage.html.loadCss(cssText);
    var bdUserCloseReason = [];
    var bdUserCoverReason = [];
    var bdUserComplainReason = [];
    for (var i = 0; i < bdUserPreferenceReason.length; i++) {
        if (bdUserPreferenceReason[i]['type'] == '0') {
            bdUserCloseReason.push(bdUserPreferenceReason[i]);
        } else {
            bdUserCoverReason.push(bdUserPreferenceReason[i]);
        }
    }

    var ads = ads || [];
    var param = (function() {
        var obj = {};
        var query = location.href.split('?')[1];
        if (!query || !query.length) {
            return;
        }
        var arrs = query.split('&');
        for (var i = 0; i < arrs.length; i++) {
            var item = arrs[i].split('=');
            obj[item[0]] = item[1];
        }
        return obj;
    })();
    if (typeof config == 'undefined') {
        config = param;
    }

    var pingback = function(args) {
        var base = 'http://eclick.baidu.com/close_feedback.jpg?',
            param = [];
        for (var key in args) {
            param.push(key + '=' + args[key]);
            console.log(param);

        }
        var img = new Image();
        img.src = base + param.join('&') + '&_=' + new Date().getTime();
    };

    var adClose = {
        init: function() {

            this.getLogo();
        },
        hoverTimer: null,
        elems: {},
        snippet: {},
        counter: 0,
        getLogo: function() {


            var me = this,
                logo = baiduCproPage.dom.find('logo')

            || baiduCproPage.dom.getByClass('logo')[0] || baiduCproPage.dom.getByClass('bd-logo1')[0] || baiduCproPage.dom.getByClass('bd-logo2')[0] || baiduCproPage.dom.getByClass('bd-logo3')[0] || baiduCproPage.dom.getByClass('bd-logo4')[0];
            // 解决页面logo加载缓慢刷不出来的问题
            if (!logo && this.counter++ < 3) {
                setTimeout(function() {
                    me.getLogo();
                }, 50);
            } else {
                me.draw(logo);
            }
        },
        draw: function(logo) {
            if (!logo) {
                return;
            }
            var me = this;
            me.coverFlag = false; //当前只有关闭广告逻辑，屏蔽广告逻辑被暂时干掉了

            var style = {
                w: baiduCproPage.dom.css(logo, 'width'),
                h: baiduCproPage.dom.css(logo, 'height'),
                b: baiduCproPage.dom.css(logo, 'bottom'),
                r: baiduCproPage.dom.css(logo, 'right')
            };
            logo.style.backgroundPosition = 0;
            logo.href = 'javascript:;';
            var closeBtn = document.createElement('a');
            var closeWrap = document.createElement('div'),
                closeCon = document.createElement('div');
            var tipWrapper = document.createElement('div');
            logo.style.height = logo.style.width = closeBtn.style.width = closeBtn.style.height = 20 + 'px';
            closeBtn.style.display = closeWrap.style.display = closeCon.style.display = 'block';


            closeBtn.id = 'closeBtn';
            closeWrap.id = 'closeWrap';
            closeCon.id = 'closeCon';

            logo.parentNode.appendChild(closeCon);
            closeCon.appendChild(closeWrap);
            closeWrap.appendChild(closeBtn);
            closeWrap.appendChild(logo);

            titleFontSize = baiduCproPage.html.select(14, 20);
            closeBtn.title = '关闭此推广位显示';
            closeBtn.title.fontSize = titleFontSize;



            /* 修改 */
            var screenX = (window.innerWidth * 2) + 'px';

            tipWrapper.id = 'tipWrapper';
            tipWrapper.style.display = 'block';
            tipWrapper.style.zIndex = 99;
            tipWrapper.style.position = 'absolute';
            tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(' + screenX + ',0,0)';
            tipWrapper.style.width = 100 + '%';
            tipWrapper.style.height = parseInt(config.rsi1) - 5 + 'px';



            var container = logo.parentNode,
                containerWrap = document.getElementById('cpro_container');
            var fSize = 14;
            var bigTitle = '您关闭此推广内容是因为',
                smallTitle = '此推广有什么问题？';

            var tpl = [];
            var coverReason = '',
                closeReason = '',
                causeOption = '';
            for (var i = 0; i < bdUserCoverReason.length; i++) {
                coverReason += ['<a index="', i, '" href="javascript:;" class="choice" id="', bdUserCoverReason[i]['id'], '">', bdUserCoverReason[i]['name'], '</a>'].join('');
            }
            for (var i = 0; i < bdUserCloseReason.length; i++) { //这是关闭按钮里面的选项
                closeReason += ['<a index="', i, '" href="javascript:;" class="choice" id="', bdUserCloseReason[i]['id'], '">', bdUserCloseReason[i]['name'], '</a>'].join('');
            }



            // 投诉推广的原因
            for (var i = 0; i < bdUserComplainReason.length; i++) {
                causeOption += ['<option value="' + bdUserComplainReason[i].option + '">' + bdUserComplainReason[i].name + '</option>'].join('');
            }
            for (var i = 0; i < bdUserComplainReason.length; i++) {
                causeOption += ['<li class="opts" data-value="' + bdUserComplainReason[i].option + '">' + bdUserComplainReason[i].name + '</li>'].join('');
            }
            //关闭感谢页
            tpl.push(['<div id="closeEnd" style="display:none">',
                '<div class="tit" style="font-size:18px;">感谢您的反馈！</div>',
                '<p class="question_tit"><span class="gobackt toAd">返回</span><a class="btn-blue" href="http://yingxiao.baidu.com/zhichi/knowledge/detail.action?channelId=3&classId=10845&knowledgeId=14394" target="_blank">了解详情</a></p>',
                '<p class="question_tit question_titp">我们已记录您对此推广内容的反馈，以便改善您今后的浏览体验。</p>',
                '</div>'
            ].join(''));


            //关闭反馈页
            tpl.push(['<div id="closeChoice"><div class="tit" style="width:auto;font-size:18px">' + bigTitle + '<span class="goback">撤销</span></div><p class="choiceWrap" style="clear:both;">',
                closeReason,
                '</p></div>',


                '</a>'
            ].join(''));



            //投诉跟踪页
            tpl.push(['<div id="closePop" style="display:none"><div class="tit" style="width:auto;font-size:' + fSize + 'px;">' + bigTitle + '<span class="goback">撤销</span></div>',
                '<div class="space">',
                '<div class="panel panel-cause">',
                '<p style="margin:0;">该推广还需要改进的有：</p>',
                '<div class="sel-panel">',
                '<input class="ipt-other" id="iptOther" type="text" value="请输入..." style="display:block;" />',

                '<ul class="causeSelect" id="causeSelect">',
                causeOption,
                '</ul>',
                /*'<select id="causeSelect">',
                causeOption,
                '</select>',*/
                '</div>',
                '</div>',
                '<div class="panel panel-email">',
                '<p style="margin:0;">常用邮箱(选填)：</p>',
                '<div class="sel-panel"><input class="i-email" id="iptEmail" type="text" /></div>',
                '</div>',
                '<div class="panel">',
                '<p class="btns" style="margin-top:0;*margin-top:0;top:6px;"><a id="affirmBtn" class="ok-btn" href="javascript:;">确认</a></p>',
                '</div>',
                '</div>',
                '</div>',
                '</a>'
            ].join(''));

            //动画弹窗对话框
            tpl.push(['<div class="pop-dialog" id="popDialog">',
                /*'<span class="closeBtn"></span>',*/
                '<a class="trapezium" id="closeTrapezium"><span class="zfx" id="zfxx"><img src="http://cpro.baidu.com/cpro/ui/luWrap/right.png"></span><span class="triangle_left" id="triangle"></span></a>',
                '<a class="sel_radio s1" href="javascript:;">反感内容</a>',
                '<a class="sel_radio s2" href="javascript:;">位置遮挡</a>',
                '<a class="sel_radio s3" href="javascript:;">返回</a>',
                '</div>'
            ].join(''));
            tipWrapper.innerHTML = tpl.join('');
            containerWrap.appendChild(tipWrapper);
            me.elems = {
                logo: logo,
                closeBtn: closeBtn,
                tipWrapper: tipWrapper,
                closeChoice: baiduCproPage.dom.find('closeChoice'),
                closeEnd: baiduCproPage.dom.find('closeEnd'),
                closePop: baiduCproPage.dom.find('closePop'),
                causeSelect: baiduCproPage.dom.find('causeSelect'),
                iptOther: baiduCproPage.dom.find('iptOther'),
                oEmail: baiduCproPage.dom.find('iptEmail'),
                showCause: baiduCproPage.dom.find('showCause'),
                inputText: '请输入...',
                oCloseWrap: baiduCproPage.dom.find('closeWrap'),
                popDialog: baiduCproPage.dom.find('popDialog')
            };
            me.setWidth();
            me.events();
            me.autoPlay();

        },
        setWidth: function() {
            var me = this;
            var containerWrap = document.getElementById('pic_container');
            var as = me.elems.popDialog.getElementsByTagName('a');
            var getcloseEnd = document.getElementById('closeEnd'),
                getcloseChoice = document.getElementById('closeChoice');
            getcloseEnd.style.paddingTop = (parseInt(tipWrapper.style.height) -90 )/2 + 'px',
            getcloseChoice.style.paddingTop = (parseInt(tipWrapper.style.height) -90)/2 + 'px';

            if (0) { // 三行
                for (var i = 0; i < as.length; i++) {
                    as[i].style.width = containerWrap.offsetWidth + 'px';
                    as[i].style.height = as[i].style.lineHeight = containerWrap.offsetHeight / as.length + 'px';
                };
            } else { // 三列
                var triangLeft = document.getElementById('triangle');
                triangLeft.style.zIndex = 9;

                /* 修改 */
                // triangLeft.style.borderWidth =  (config.rsi1) / 2 + 'px';
                //triangLeft.style.borderTop = triangLeft.style.borderBottom = triangLeft.style.borderLeftWidth = (config.rsi1) / 2 + 'px'
                var zfxX = document.getElementById('zfxx');




                zfxX.style.height = config.rsi1 + 'px';

                me.elems.popDialog.className = 'pop-dialog fl';
                for (var i = 0; i < as.length; i++) {
                    var ass = me.elems.popDialog.getElementsByTagName('a')[0].getElementsByTagName('span')[0];
                    as[i].style.float = 'left';
                    as[i].style.width = me.elems.popDialog.offsetWidth / as.length + 'px';
                    zfxX.style.width = as[0].style.width = me.elems.popDialog.offsetWidth / as.length * 0.3 + 's';
                    var getZfxImg = zfxX.getElementsByTagName('img')[0];

                    getZfxImg.style.marginTop = (parseInt(as[0].style.height) - 42)/2 + 'px';


                    as[i].style.width = (me.elems.popDialog.offsetWidth - me.elems.popDialog.offsetWidth / as.length * 0.3) / (as.length - 1) + 'px';
                    // var aSpan = me.elems.popDialog.offsetWidth/as.length*0.1+'px';
                    triangLeft.style.position = 'absolute';
                    triangLeft.style.top = 0 + 'px';
                    triangLeft.style.left = me.elems.popDialog.offsetWidth / as.length * 0.3 + 'px',
                    triangLeft.style.borderTop = triangLeft.style.borderBottom = config.rsi1/2 + 'px solid transparent';




                    as[i].style.height = as[i].style.lineHeight = containerWrap.offsetHeight + 'px';
                    //ass.style.width = me.elems.popDialog.offsetWidth/as.length -20+'px'
                };
            }
        },
        showDiv: function() {
                       var me = this;
                       
                        me.elems.closeChoice.style.display = 'none';
                        me.elems.closeEnd.style.display = 'none';
                        me.elems.tipWrapper.style.display = 'block';
                        me.elems.popDialog.style.display = 'block';
                        /* 修改 */
                        tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(0,0,0)';
                        // move(me.elems.tipWrapper,{'opacity':0},0,'linear');
                        setTimeout(function() {
                            // move(me.elems.tipWrapper,{'opacity':1},1000,'linear');
                        }, 500);
                        me.setWidth();
                        me.autoClose();
                        
        },
        autoPlay: function() {
            var me = this;
            var scrollBox = me.elems.oCloseWrap;

            var as = scrollBox.getElementsByTagName('a');
            var aDiv = scrollBox.getElementsByTagName('div');
            me.idx = 0;
            var timer = null;
            autoPlay();

            function autoPlay() {
                timer = setInterval(function() {
                    play(me.idx++);
                }, 3000);
            }

            function play(idx) {

                move(scrollBox, {

                    'bottom': me.idx * as[0].offsetHeight
                }, 400, 'easeBothStrong', function() {
                    if (parseInt(scrollBox.style.bottom) >= parseInt(me.idx * as[0].offsetHeight)) {
                       // scrollBox.appendChild(as[0]);

                       // scrollBox.style.bottom =0;
                        //
                        var children = scrollBox.childNodes;
                        children[1].parentNode.insertBefore(children[1], children[0]);
                        scrollBox.style.bottom=0;
                        me.idx = 0;
                        
                        
                    }
                });
                stopPlay();
            }

            function stopPlay() {
                scrollBox.onmouseover = function() {
                    clearInterval(timer);
                }
                scrollBox.onmouseout = function() {
                    autoPlay();
                }
            }
        },
        autoClose: function() {
            var me = this;
            var isec = 20; // 20秒自动关闭
            var timer = setInterval(function() {
                // 有操作记录，清除自动关闭
                if (me.elems.closeEnd.style.display == 'block' || me.elems.closeChoice.style.display == 'block' || me.elems.closePop.style.display == 'block') {
                    clearInterval(timer);
                    return;
                }
                // 自动关闭
                if (--isec <= 0) {
                    clearInterval(timer);
                    // 自动关闭遮罩
                    move(me.elems.tipWrapper, {
                        'opacity': 0
                    }, 1000, 'linear');
                    setTimeout(function() {
                        me.elems.tipWrapper.style.display = 'none';
                        me.elems.popDialog.style.display = 'none';
                    }, 1000);
                }
            }, 1000);
        },
        events: function() {
            var me = this;
            var hasClass = baiduCproPage.dom.hasClass;
            if (me.coverFlag) {
                //hover 关闭按钮
                baiduCproPage.eventUtil.hover(me.elems.closeBtn,
                    function() {
                        clearTimeout(me.hoverTimer);
                        me.elems.closeWrapper.style.display = 'block';
                    },
                    function() {
                        me.hoverTimer = setTimeout(function() {
                            me.elems.closeWrapper.style.display = 'none';
                        }, 20000);
                    });

                baiduCproPage.eventUtil.hover(me.elems.closeWrapper,
                    function() {
                        clearTimeout(me.hoverTimer);
                    },
                    function() {
                        me.hoverTimer = setTimeout(function() {
                            me.elems.closeWrapper.style.display = 'none';
                        }, 20000);
                    });
                //点击 关闭 反馈按钮

                baiduCproPage.eventUtil.addEvent(me.elems.closeWrapper, 'mouseover', function(e) {
                    var target = e.target || e.srcElement;
                    if (target.className == 'closeA') {

                        target.getElementsByTagName('span')[0].style.backgroundImage = 'url(http://cpro.baidustatic.com/cpro/exp/closead/img/arr.png)';

                    }
                    if (target.tagName.toLowerCase() == 'span') {
                        target.style.backgroundImage = 'url(http://cpro.baidustatic.com/cpro/exp/closead/img/arr.png)';
                    }
                });

                baiduCproPage.eventUtil.addEvent(me.elems.closeWrapper, 'mouseout', function(e) {
                    var target = e.target || e.srcElement;
                    if (target.className == 'closeA') {
                        target.getElementsByTagName('span')[0].style.backgroundImage = 'url(http://cpro.baidustatic.com/cpro/exp/closead/img/arr_hover.png)';
                    }
                    if (target.tagName.toLowerCase() == 'span') {
                        target.style.backgroundImage = 'url(http://cpro.baidustatic.com/cpro/exp/closead/img/arr_hover.png)';
                    }
                });
              /**  baiduCproPage.eventUtil.addEvent(me.elems.closeWrapper, 'click', function(e) {
                    var target = e.target || e.srcElement;
                    while (target.tagName.toLowerCase() != 'a') {
                        target = target.parentNode;
                    }
                    if (target.className == 'closeA') {
                        me.elems.coverChoice.style.display = 'none';
                        me.elems.closeChoice.style.display = 'block';
                        pingback({
                            type: 1,
                            action: 1,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            dspid: 4
                        });
                    } else {
                        me.elems.coverChoice.style.display = 'block';
                        me.elems.closeChoice.style.display = 'none';
                        pingback({
                            type: 2,
                            action: 2,
                            filter: 0,
                            adn: 1,
                            list: 6,
                            s: preferenceInfo
                        });
                    }
                    me.elems.tipWrapper.style.display = 'block';
                }); **/


                baiduCproPage.eventUtil.addEvent(me.elems.closeWrapper, 'hover', function(e) {
                    var target = e.target || e.srcElement;
                    while (target.tagName.toLowerCase() != 'a') {
                        target = target.parentNode;
                    }
                    if (target.className == 'closeA') {
                        me.elems.coverChoice.style.display = 'none';
                        me.elems.closeChoice.style.display = 'block';
                        pingback({
                            type: 1,
                            action: 1,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            dspid: 4
                        });
                    } else {
                        me.elems.coverChoice.style.display = 'block';
                        me.elems.closeChoice.style.display = 'none';
                        pingback({
                            type: 2,
                            action: 2,
                            filter: 0,
                            adn: 1,
                            list: 6,
                            s: preferenceInfo,
                            dspid: 4
                        });
                    }
                    me.elems.tipWrapper.style.display = 'block';
                });
            } else {
                // 只有关闭逻辑时直接点击 X 触发关闭
                /* baiduCproPage.eventUtil.addEvent(me.elems.closeBtn,'click',function(e){
                                    var target = e.target|| e.srcElement;

                                    me.elems.closeChoice.style.display = 'block';
                                    me.elems.closeEnd.style.display = 'none';
                                    pingback({type:1,action:1,filter:0,adn:1,list:6,s:preferenceInfo});
                                    me.elems.tipWrapper.style.display = 'block';
                                });


                 baiduCproPage.eventUtil.addEvent(me.elems.closeBtn,'mouseover',function(e){
                                    var target = e.target|| e.srcElement;
                                     while(target.tagName.toLowerCase()!='a'){
                                        target = target.parentNode;
                                    }
                                    if(target.className =='question_choice'){

                                        me.elems.closeChoice.style.display = 'block';
                                    me.elems.closeEnd.style.display = 'none';

                                    }
                  me.elems.tipWrapper.style.display = 'block';
                                });*/


                baiduCproPage.eventUtil.addEvent(me.elems.closeBtn , 'click', function(e) {
                  
                    
                    var target = e.target || e.srcElement;
                    if (target.id == 'closeBtn'   ) {
                    var id = target.id;
                        me.showDiv();
                        pingback({
                            type: 1,
                            action: 1,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            reasonid: id,
                            dspid: 4
                        });
                       /** var id = target.id;
                        me.elems.closeChoice.style.display = 'none';
                        me.elems.closeEnd.style.display = 'none';
                        me.elems.tipWrapper.style.display = 'block';
                        me.elems.popDialog.style.display = 'block';
                       
                        tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(0,0,0)';
                        // move(me.elems.tipWrapper,{'opacity':0},0,'linear');
                        setTimeout(function() {
                            // move(me.elems.tipWrapper,{'opacity':1},1000,'linear');
                        }, 500);
                        me.setWidth();
                        me.autoClose();
                        pingback({
                            type: 1,
                            action: 1,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            reasonid: id,
                            dspid: 4
                        }); **/
                        
                    }
                });

                baiduCproPage.eventUtil.addEvent(me.elems.popDialog, 'click', function(e) {
                    var target = e.target || e.srcElement;
                    if (target.className == 'sel_radio s1') {
                        // 跳转反馈页
                        me.elems.closeChoice.style.display = 'block';
                        me.elems.tipWrapper.style.display = 'block';
                        me.elems.popDialog.style.display = 'none';
                        pingback({
                            type: 1,
                            action: 4,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            dspid: 4
                        });


                    } else if (target.className == 'sel_radio s2') {
                        // 跳转感谢页
                        me.elems.closeEnd.style.display = 'block';
                        me.elems.tipWrapper.style.display = 'block';
                        me.elems.popDialog.style.display = 'none';
                        pingback({
                            type: 1,
                            action: 3,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            dspid: 4
                        });

                    } else if (target.className == 'sel_radio s3') {
                        pingback({
                            type: 1,
                            action: 6,
                            filter: 0,
                            adn: 1,
                            list: 1,
                            s: preferenceInfo,
                            dspid: 4
                        });
                        move(me.elems.tipWrapper, {
                            'opacity': 0
                        }, 1000, 'linear');
                        setTimeout(function() {
                            me.elems.tipWrapper.style.display = 'none';
                            me.elems.popDialog.style.display = 'none';
                        }, 1000);
                    }
                });



            }

            //点击关闭--反馈页事件
            baiduCproPage.eventUtil.addEvent(me.elems.closeChoice, 'click', function(e) {

                //clearTimeout(me.timer);
                var target = e.target || e.srcElement;
                if (hasClass(target, 'goback') || hasClass(target.parentNode, 'goback')) {

                    me.elems.tipWrapper.style.display = 'block';
                    me.elems.popDialog.style.display = 'block';
                    me.elems.closeChoice.style.display = 'none';
                    pingback({
                        type: 1,
                        action: 7,
                        filter: 0,
                        adn: 1,
                        list: 1,
                        s: preferenceInfo,
                        dspid: 4
                    });
                }
              if (hasClass(target, 'choice')) {

                     var id = target.id;
                     me.elems.closeEnd.style.display = 'block';
                     me.elems.closePop.style.display = me.elems.closeChoice.style.display = me.elems.closePop.style.display = 'none';

                     pingback({
                         type: 1,
                         action:5,
                         filter: 0,
                         adn: 1,
                         list: 1,
                         s: preferenceInfo,
                         reasonid: id,
                         dspid: 4
                     });
                 }




            });

            //点击关闭--感谢页事件
            baiduCproPage.eventUtil.addEvent(me.elems.closeEnd, 'click', function(e) {
                var target = e.target || e.srcElement;
                if (hasClass(target, 'gobackt') || hasClass(target.parentNode, 'gobackt')) {
                    me.elems.closeChoice.style.display = 'none';
                    me.elems.closeEnd.style.display = 'none';
                    me.elems.popDialog.style.display = 'block';



                    pingback({
                        type: 1,
                        action: 8,
                        filter: 0,
                        adn: 1,
                        list: 1,
                        s: preferenceInfo,
                        dspid: 4
                    });

                }

            });

            //点击投诉跟踪-投诉跟踪事件
            baiduCproPage.eventUtil.addEvent(me.elems.closePop, 'click', function(e) {

                //clearTimeout(me.timer);
                var target = e.target || e.srcElement;

                if (hasClass(target, 'goback') || hasClass(target.parentNode, 'goback')) {
                    me.elems.closeChoice.style.display = 'block';
                    me.elems.closePop.style.display = 'none';
                    pingback({
                        type: 1,
                        action: 12,
                        filter: 0,
                        adn: 1,
                        list: 1,
                        s: preferenceInfo,
                        dspid: 4
                    });

                }
                // 确定按钮
                if (hasClass(target, 'ok-btn')) {

                    var sEmail = me.elems.oEmail.value;
                    var sVal = me.elems.iptOther.style.display == 'none' ? me.elems.showCause.innerHTML : me.elems.iptOther.value;



                    /*if( me.elems.causeSelect.value == 0 ){
                        alert('请选择投诉该推广的原因!');
                        return;
                    }*/
                    if ((me.elems.iptOther.style.display != 'none' && me.elems.iptOther.value == me.elems.inputText) || me.elems.iptOther.value == "") {
                        alert('请输入投诉该推广的原因!');
                        return;
                    }

                    if (me.elems.oEmail.value != '') {
                        var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reEmail.test(me.elems.oEmail.value)) {
                            alert('邮箱地址不正确!');
                            return;
                        }
                    }
                    pingback({
                        type: 1,
                        action: 10,
                        filter: 0,
                        adn: 1,
                        list: 0,
                        s: preferenceInfo,
                        email: sEmail,
                        report_reason: sVal,
                        dspid: 4
                    });
                    // 显示closeEnd感激反馈页
                    me.elems.closePop.style.display = 'none';
                    me.elems.closeChoice.style.display = 'none';
                    me.elems.closeEnd.style.display = 'block';

                }

                // 下拉选项 bind click
                // || hasClass(target,'ipt-other')
                if (hasClass(target, 'show-cause')) {
                    var childNodes = baiduCproPage.dom.getChildElement(target.parentNode);
                    var childNode;
                    for (var i = 0; i < childNodes.length; i++) {
                        if (childNodes[i].className == 'causeSelect') {
                            childNode = childNodes[i];
                        }
                    }
                    if (childNode.style.display == 'none') {
                        baiduCproPage.dom.removeClass(target.parentNode, 'on');
                        baiduCproPage.dom.addClass(target.parentNode, 'on');
                        childNode.style.display = 'block';
                    } else {
                        baiduCproPage.dom.removeClass(target.parentNode, 'on');
                        childNode.style.display = 'none';
                    }
                    if (e.stopPropagation) {
                        e.stopPropagation();
                    } else {
                        e.cancelBubble = true;
                    }
                }

                if (hasClass(target, 'opts')) {
                    me.elems.showCause.innerHTML = target.innerHTML;
                    target.parentNode.style.display = 'none';
                    target.parentNode.parentNode.className = 'sel-panel';

                    // 其他选项
                    if (me.elems.showCause.innerHTML == me.elems.inputText) {
                        me.elems.iptOther.style.display = 'block';
                        me.elems.iptOther.focus();
                        me.elems.iptOther.value = '';
                    } else {
                        me.elems.iptOther.style.display = 'none';
                    }

                }
                /*if( wrap_wid<=120 && wrap_hei<=270 ){
                    bigTitle = '将关闭推广';
                    smallTitle = '推广有何问题？';
                    tipWrapper.className+='tipWrapper';
                    iptOtherWid.style.width=iptOtherWid+'px';
                }*/

            });

            /*
             * 清除文本框默认数据,并显示下拉框选项
             */
            baiduCproPage.eventUtil.addEvent(me.elems.iptOther, 'click', function(e) {
                //me.elems.causeSelect.style.display = 'block';
                //baiduCproPage.dom.addClass(this.parentNode,'on');
                if (this.value == me.elems.inputText) {
                    this.value = '';
                }
                if (e.stopPropagation) {
                    e.stopPropagation();
                } else {
                    e.cancelBubble = true;
                }
            });

            baiduCproPage.eventUtil.addEvent(me.elems.iptOther, 'blur', function(e) {
                if (this.value == '') {
                    this.value = me.elems.inputText;
                }
            });

            /* 修改 关闭*/
            closeTrapezium.onclick = function() {
                    var screenX = (window.innerWidth * 2) + 'px';
                    tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(' + screenX + ',0,0)';
                }
                /*baiduCproPage.eventUtil.addEvent(me.elems.iptOther,'keyup',function(e){
                    me.elems.causeSelect.style.display = 'none';
                    baiduCproPage.dom.removeClass(this.parentNode,'on');
                    if( this.value == '' ){
                        me.elems.causeSelect.style.display = 'block';
                        baiduCproPage.dom.addClass(this.parentNode,'on');
                    }
                    if(e.stopPropagation){ e.stopPropagation(); } else{ e.cancelBubble = true; }
                });*/

            // 模拟下拉
            baiduCproPage.eventUtil.addEvent(me.elems.closePop, 'mouseover', function(e) {
                var target = e.target || e.srcElement;
                if (hasClass(target, 'opts')) {
                    var childLen = baiduCproPage.dom.getChildElement(target.parentNode);
                    for (var i = 0; i < childLen.length; i++) {
                        childLen[i].style.backgroundColor = '';
                    }
                    target.style.backgroundColor = '#f5f5f5';
                }
            });
            // mouseout remove backgroundColor
            baiduCproPage.eventUtil.addEvent(me.elems.closePop, 'mouseout', function(e) {
                var target = e.target || e.srcElement;
                if (hasClass(target, 'opts')) {
                    target.style.backgroundColor = '';
                }
            });

            baiduCproPage.eventUtil.addEvent(document, 'click', function(e) {
                var target = e.target || e.srcElement;
                if (target.className != 'causeSelect') {

                    baiduCproPage.dom.getByClass('causeSelect')[0].style.display = 'none';
                    baiduCproPage.dom.removeClass(baiduCproPage.dom.getByClass('causeSelect')[0].parentNode, 'on');
                }
            });



            if (me.coverFlag) {

                //点击屏蔽--反馈页事件
                baiduCproPage.eventUtil.addEvent(me.elems.coverChoice, 'click', function(e) {
                    var target = e.target || e.srcElement;
                    if (hasClass(target, 'goback') || hasClass(target.parentNode, 'goback')) {
                        me.elems.tipWrapper.style.display = 'none';
                        // pingback({type:2,action:5,filter:0,adn:1,list:6,s:preferenceInfo,dspid:4});
                    }
                    if (hasClass(target, 'choice')) {
                        var id = target.id;
                        me.elems.coverChoice.style.display = 'none';
                        me.elems.coverEnd.style.display = 'block';
                        me.elems.closePop.style.display = 'none';
                        me.elems.closeEnd.style.display = 'block';
                        // pingback({type:2,action:3,filter:1,adn:1,list:1,s:preferenceInfo,reasonid:id,dspid:4});

                    }
                });
                //点击屏蔽--感谢页事件
                baiduCproPage.eventUtil.addEvent(me.elems.coverEnd, 'click', function(e) {
                    var target = e.target || e.srcElement;
                    if (hasClass(target, 'goback') || hasClass(target.parentNode, 'goback')) {
                        me.elems.coverChoice.style.display = 'block';
                        me.elems.coverEnd.style.display = 'none';
                        me.elems.closePop.style.display = 'none';
                        // pingback({type:2,action:4,filter:2,adn:1,list:6,s:preferenceInfo,dspid:4});

                    }
                });
            }
        }



    };

    adClose.init();

})();

function move(obj, json, duration, fx, callback) {
    var oTimer = null;
    var d = duration || 1000;
    var j = {};
    for (var attr in json) {
        j[attr] = {};
        if (attr == 'opacity') {
            j[attr].b = Math.round(css(obj, attr));
            j[attr].c = json[attr] * 100 - j[attr].b
        } else {
            j[attr].b = parseInt(css(obj, attr));
            j[attr].c = json[attr] - j[attr].b
        }
    }
    obj.style[attr] = json[attr];
    var fx = fx || 'linear';
    var t1 = new Date().getTime();
    oTimer = setInterval(function() {
        var t = new Date().getTime() - t1;
        if (t >= d) {
            t = d
        }
        for (var attr in json) {
            var v = Tween[fx](t, j[attr].b, j[attr].c, d);
            if (attr == 'opacity') {
                obj.style[attr] = v / 100;
                obj.style.filter = "alpha(opacity=" + v + ")"
            } else {
                obj.style[attr] = v + 'px'
            }
            css(obj, attr, v)
        }
        if (t == d) {
            clearInterval(oTimer);
            callback && callback.call(obj)
        }
    }, 16)
}
/*---------------------*/

removeClick();

function removeClick() {

    var cproContainer = document.querySelector('#cpro_container');
    var picContainer = document.querySelector('#pic_container'),
    picContainerDiv = picContainer.getElementsByTagName('div')[0];
    picContainerDiv.style.position = 'relative';

    var Countdown =  document.createElement('div');
    Countdown.id = 'Countdown';
    picContainerDiv.appendChild(Countdown);




    var oDiv = picContainer.querySelectorAll('div')[0];
    var divUrl = oDiv.getAttribute('onclick') ;
    if (divUrl) {
        var url = divUrl.substring(divUrl.indexOf("('") + 2, divUrl.length - 3);

        oDiv.setAttribute('onclick', 'null');


    }


    var num = 3;
    var timer = null;
    var startTime, endTime;

    // 绑定事件
    picContainer.addEventListener('touchstart', onStart, false);
    picContainer.addEventListener('touchend', onEnd, false);

    function onStart() {
        Countdown.style.display = 'block';
        num = 3; // 每次按下时候赋值
        startTime = new Date();

        // 一按下就显示三
        //console.log(num);

        timer = setInterval(function() {
            num--;
            Countdown.innerHTML = '关闭前' + num +'s';

            // 当num减到0时，关闭定时器并且头部显示
            if (num == 0) {
                clearInterval(timer);
                tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(0,0,0)';
            }

        }, 1000);
    }

    function onEnd() {
        endTime = new Date();
        // 小于3秒抬起跳转，大于三秒，显示头部
        if (endTime - startTime < 3000 || endTime - startTime > 3000) {
            window.location.href = url;
        } else {
            tipWrapper.style.transform = tipWrapper.style.MozTransform = tipWrapper.style.WebkitTransform = 'translate3d(0,0,0)';
        }
    }


}



/*----------------------*/



function css(obj, attr, value) {
    if (!obj) {
        return false
    }
    if (arguments.length == 2) {
        if (attr == 'scale' || attr == 'rotate' || attr == 'rotateX' || attr == 'rotateY' || attr == 'scaleX' || attr == 'scaleY' || attr == "translateZ" || attr == "translateX" || attr == "translateY" || attr == "skewY" || attr == "skewX") {
            if (!obj.$Transform) {
                obj.$Transform = {}
            }
            switch (attr) {
                case 'scale':
                case 'scaleX':
                case 'scaleY':
                    return typeof(obj.$Transform[attr]) == 'number' ? obj.$Transform[attr] : 100;
                    break;
                default:
                    return obj.$Transform[attr] ? obj.$Transform[attr] : 0
            }
        }
        var sCur = obj.currentStyle ? obj.currentStyle[attr] : document.defaultView.getComputedStyle(obj, false)[attr];
        if (attr == 'opacity') {
            return Math.round((parseFloat(sCur) * 100))
        } else {
            return parseInt(sCur)
        }
    } else if (arguments.length == 3) {
        switch (attr) {
            case 'scale':
            case 'scaleX':
            case 'scaleY':
            case 'rotate':
            case 'rotateX':
            case 'rotateY':
            case 'translateZ':
            case 'translateX':
            case 'translateY':
            case 'skewY':
            case 'skewX':
                setCss3(obj, attr, value);
                break;
            case 'width':
            case 'height':
            case 'paddingLeft':
            case 'paddingTop':
            case 'paddingRight':
            case 'paddingBottom':
                value = Math.max(value, 0);
            case 'left':
            case 'top':
            case 'marginLeft':
            case 'marginTop':
            case 'marginRight':
            case 'marginBottom':
                if (typeof value == "string") {
                    obj.style[attr] = value
                } else {
                    obj.style[attr] = value + 'px'
                }
                break;
            case 'opacity':
                obj.style.filter = "alpha(opacity:" + value + ")";
                obj.style.opacity = value / 100;
                break;
            default:
                obj.style[attr] = value
        }
    }
    return function(attr_in, value_in) {
        css(obj, attr_in, value_in)
    }
}

function setCss3(obj, attr, value) {
    var sTr = "";
    var sVal = "";
    var arr = ["Webkit", "Moz", "O", "ms", ""];
    if (!obj["$Transform"]) {
        obj["$Transform"] = {}
    }
    obj["$Transform"][attr] = parseInt(value);
    for (sTr in obj["$Transform"]) {
        switch (sTr) {
            case 'scale':
            case 'scaleX':
            case 'scaleY':
                sVal += sTr + "(" + (obj["$Transform"][sTr] / 100) + ") ";
                break;
            case 'rotate':
            case 'rotateX':
            case 'rotateY':
            case 'skewY':
            case 'skewX':
                sVal += sTr + "(" + (obj["$Transform"][sTr]) + "deg) ";
                break;
            case 'translateZ':
            case 'translateX':
            case 'translateY':
                sVal += sTr + "(" + (obj["$Transform"][sTr]) + "px) ";
                break
        }
    }
    for (var i = 0; i < arr.length; i++) {
        obj.style[arr[i] + "Transform"] = sVal
    }
}
var Tween = {
    linear: function(t, b, c, d) {
        return c * t / d + b
    },
    easeIn: function(t, b, c, d) {
        return c * (t /= d) * t + b
    },
    easeOut: function(t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b
    },
    easeBoth: function(t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t + b
        }
        return -c / 2 * ((--t) * (t - 2) - 1) + b
    },
    easeInStrong: function(t, b, c, d) {
        return c * (t /= d) * t * t * t + b
    },
    easeOutStrong: function(t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b
    },
    easeBothStrong: function(t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t * t * t + b
        }
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b
    },
    elasticIn: function(t, b, c, d, a, p) {
        if (t === 0) {
            return b
        }
        if ((t /= d) == 1) {
            return b + c
        }
        if (!p) {
            p = d * 0.3
        }
        if (!a || a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else {
            var s = p / (2 * Math.PI) * Math.asin(c / a)
        }
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b
    },
    elasticOut: function(t, b, c, d, a, p) {
        if (t === 0) {
            return b
        }
        if ((t /= d) == 1) {
            return b + c
        }
        if (!p) {
            p = d * 0.3
        }
        if (!a || a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else {
            var s = p / (2 * Math.PI) * Math.asin(c / a)
        }
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b
    },
    elasticBoth: function(t, b, c, d, a, p) {
        if (t === 0) {
            return b
        }
        if ((t /= d / 2) == 2) {
            return b + c
        }
        if (!p) {
            p = d * (0.3 * 1.5)
        }
        if (!a || a < Math.abs(c)) {
            a = c;
            var s = p / 4
        } else {
            var s = p / (2 * Math.PI) * Math.asin(c / a)
        }
        if (t < 1) {
            return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b
        }
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b
    },
    backIn: function(t, b, c, d, s) {
        if (typeof s == 'undefined') {
            s = 1.70158
        }
        return c * (t /= d) * t * ((s + 1) * t - s) + b
    },
    backOut: function(t, b, c, d, s) {
        if (typeof s == 'undefined') {
            s = 1.70158
        }
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b
    },
    backBoth: function(t, b, c, d, s) {
        if (typeof s == 'undefined') {
            s = 1.70158
        }
        if ((t /= d / 2) < 1) {
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b
        }
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b
    },
    bounceIn: function(t, b, c, d) {
        return c - Tween['bounceOut'](d - t, 0, c, d) + b
    },
    bounceOut: function(t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b
        }
        return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b
    },
    bounceBoth: function(t, b, c, d) {
        if (t < d / 2) {
            return Tween['bounceIn'](t * 2, 0, c, d) * 0.5 + b
        }
        return Tween['bounceOut'](t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b
    }
}